package com.guang.alicoud.nacos;

import com.guang.alicloud.feign.api.api.ProductCenterFeignApi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableDiscoveryClient
public class AlicoudNacosApplication {

    public static void main(String[] args) {
        SpringApplication.run(AlicoudNacosApplication.class, args);
    }

    @RestController
    class EchoController implements ProductCenterFeignApi {
        @RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)
        public String echo(@PathVariable String string) {
            System.out.println("請求來了");
            return "Hello Nacos Discovery " + string;
        }

        @Override
        public String selectProductInfoById(String productNo) {
            System.out.println("請求來了" + productNo);
            return "Hello Nacos Discovery " + 1/Integer.parseInt(productNo);
        }
    }
}
